package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmHouXuanYaoWuKu;
import com.ruoyi.web.admin.service.ITdmHouXuanYaoWuKuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 候选药物库Controller
 * 
 * @author ly
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/admin/TdmHouXuanYaoWuKu")
public class TdmHouXuanYaoWuKuController extends BaseController
{
    @Autowired
    private ITdmHouXuanYaoWuKuService tdmHouXuanYaoWuKuService;

    /**
     * 查询候选药物库列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmHouXuanYaoWuKu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmHouXuanYaoWuKu tdmHouXuanYaoWuKu)
    {
        startPage();
        List<TdmHouXuanYaoWuKu> list = tdmHouXuanYaoWuKuService.selectTdmHouXuanYaoWuKuList(tdmHouXuanYaoWuKu);
        return getDataTable(list);
    }

    /**
     * 导出候选药物库列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmHouXuanYaoWuKu:export')")
    @Log(title = "候选药物库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmHouXuanYaoWuKu tdmHouXuanYaoWuKu)
    {
        List<TdmHouXuanYaoWuKu> list = tdmHouXuanYaoWuKuService.selectTdmHouXuanYaoWuKuList(tdmHouXuanYaoWuKu);
        ExcelUtil<TdmHouXuanYaoWuKu> util = new ExcelUtil<TdmHouXuanYaoWuKu>(TdmHouXuanYaoWuKu.class);
        util.exportExcel(response, list, "候选药物库数据");
    }

    /**
     * 获取候选药物库详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmHouXuanYaoWuKu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmHouXuanYaoWuKuService.selectTdmHouXuanYaoWuKuById(id));
    }

    /**
     * 新增候选药物库
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmHouXuanYaoWuKu:add')")
    @Log(title = "候选药物库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmHouXuanYaoWuKu tdmHouXuanYaoWuKu)
    {
        return toAjax(tdmHouXuanYaoWuKuService.insertTdmHouXuanYaoWuKu(tdmHouXuanYaoWuKu));
    }

    /**
     * 修改候选药物库
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmHouXuanYaoWuKu:edit')")
    @Log(title = "候选药物库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmHouXuanYaoWuKu tdmHouXuanYaoWuKu)
    {
        return toAjax(tdmHouXuanYaoWuKuService.updateTdmHouXuanYaoWuKu(tdmHouXuanYaoWuKu));
    }

    /**
     * 删除候选药物库
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmHouXuanYaoWuKu:remove')")
    @Log(title = "候选药物库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmHouXuanYaoWuKuService.deleteTdmHouXuanYaoWuKuByIds(ids));
    }
}
